Handle ix_addk rcode correctly during master swing - #6132
Open
riverszhang89 wants to merge 1 commit into
Open
Conversation
ERR_NOMASTER is treated as a duplicate key error, which causes upsert to misbehave during master swing: an upsert may miss its index entry, or may fail incorrectly during verify-retry. Case 1) upsert misses its index entry ``` mydb4> create table t2 (i int primary key)$$ [create table t2 (i int primary key)] rc 0 ``` Upsert receives a good rcode, but misses its index entry: ``` mydb4> insert into t2 values(3) on conflict do nothing (rows inserted=1) [insert into t2 values(3) on conflict do nothing] rc 0 mydb4> select * from t2 (i=3) mydb4> select count(*) from t2 where i = 3 (count(*)=0) ``` Case 2) upsert fails incorrectly during verify-retry Insert-on-conflict-do-nothing, still receives a dupkey error: ``` mydb4> begin [begin] rc 0 mydb4> insert into t2 values(6) on conflict do nothing [insert into t2 values(6) on conflict do nothing] rc 0 mydb4> insert into t2 values(6) on conflict do nothing [insert into t2 values(6) on conflict do nothing] rc 0 mydb4> update t2 set i = sleep(1) where i = 1 [update t2 set i = sleep(1) where i = 1] rc 0 mydb4> commit [commit] failed with rc 2 Transaction is uncommittable: Duplicate insert on key 'COMDB2_PK' in table 't2' index 0 ``` Database logs the following: ``` [ERROR] Forced VERIFY-FAIL for uncommittable blocksql transaction ``` Signed-off-by: Rivers Zhang <hzhang320@bloomberg.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ERR_NOMASTER is treated as a duplicate key error, which causes upsert to misbehave during master swing: an upsert may miss its index entry, or may fail incorrectly during verify-retry.
Case 1) upsert misses its index entry
Upsert receives a good rcode, but misses its index entry:
Case 2) upsert fails incorrectly during verify-retry
Insert-on-conflict-do-nothing, still receives a dupkey error:
Database logs the following: